import unittest


class testDemo01(unittest.TestCase):
    def setUp(self):
        print('Start')

    def tearDown(self):
        print('End')

    def test01(self):
        print('This is demo01-test01.')

    def test02(self):
        print('This is demo01-test02.')

    def test03(self):
        print('This is demo01-test03.')


class testDemo02(unittest.TestCase):
    def test04(self):
        print('This is demo02-test04.')

    def test05(self):
        print('This is demo02-test05.')


if __name__ == '__main__':
    # 构建测试套件
    # 特别说明: tests参数类型必须是可迭代的, 比如元组或者列表
    # suite01 = unittestdemo.TestSuite(tests=[testDemo01('test01')])
    # suite02 = unittestdemo.TestSuite(tests=(suite01,testDemo02('test04')))
    # r = unittestdemo.TestResult()
    # suite02.run(result=r)
    # print(r.__dict__)

    suite = unittest.TestSuite()
    suite.addTest(testDemo01('test01'))
    suite.addTests([testDemo01('test02'), testDemo02('test04')])
    r = unittest.TestResult()
    suite.run(result=r)
    print(r.__dict__)
